Chris Pollett > Old Classes >
CS185c

( Print View )

Student Corner:
  [Grades Sec5]

  [Submit Sec5]

  [Class Sign Up Sec5]

  [
Lecture Notes]
  [Discussion Board]

Course Info:
  [Texts & Links]
  [Topics/Outcomes]
  [Outcomes Matrix]
  [Grading]
  [HW/Quiz Info]
  [Exam Info]
  [Regrades]
  [Honesty]
  [Additional Policies]
  [Announcements]

HWs and Quizzes:
  [Hw1]  [Hw2]  [Hw3]
  [Hw4]  [Quizzes]  [Project]

Practice Exams:
  [Mid]  [Final]

                           












HW#3 --- last modified February 10 2019 21:54:15..

Solution set.

Due date: Apr 11

Files to be submitted:
  Hw3.zip

Purpose:To experiment more with views and more UI components, to create an app that uses a web service.

Related Course Outcomes:

The main course outcomes covered by this assignment are:

LO2 -- Write a mobile application that involves GUI components and makes use of touch events to manipulate these components.

LO3 -- Write a mobile application that uses the mobile devices Networking or Telephony APIs.

Specification:

For this homework, you will create a mood impressions phone app and server. All of your code should be put in the Hw3 zip folder. You should have a readme.txt file saying how to run your code, the team members, and their IDs. People's moods can vary from green (enthusiastic) to red (unenthusiastic) about a topic. Someone who has no impression about a topic has a white mood. For this assignment, you will need to write a MoodServer.java program that listens on port 7890. When a connection is established to your server, it sends to its output stream:

Mood Server

Your phone app can then send the server one of four kinds of messages: (1) a register name message, (2) a set topic message, (3) a set mood message, (4) a status message. To messages of type 1-3 the mood server responds either "Okay\n" if the action was successfully applied "Sorry\n" if it was not. It then terminates the connection. The format of each of the messages is a single line terminated by a newline character. More specifically, a register message looks like:

Register:Bobby Smith

i.e., Register:some_name followed by a new line. Okay should be returned if your program succeeds in storing (some_name, 0) in an HashMap moods, a field of your server class. Otherwise, it should return Sorry. It might return Sorry if someone has already registered with that name.

A set a topic message might look like:

Topic:C. Elegans is the best worm evar!

This should try to store the string "C. Elegans is the best worm evar!" into a String field topic of your server class. It should also set to 0 the values of each key stored in the moods HashMap. It should return Okay if it succeeds and Sorry otherwise.

A mood message might look like: Mood:2:Bobby Smith

or in general Mood:some_num_between_1_and_5:some_name. Here 1 represents red, and 5 represents green. 2 is yellow, 3 is orange, 4 vermilion. The server should return Okay if some_name is in the HashMap moods and it was able to give that key the value between 1 and 5.

A status message looks like:

Status

It should return a line for the topic and a mood line for each name stored in moods. More specifically, an example response might look like:

Topic:C. Elegans is the best worm evar!
Mood:2:Bobby Smith
Mood:5:Robin Hungry
Mood:0:Ian Notpay Attention

Your phone app should always operate in portrait mode. Your phone app should have two screens: A settings screen and a mood viewer screen. A bar on the bottom of the screen should select between these two screens. In the settings screen there should be two fields with labels Server and Name. There should be an Apply button, which when clicked stores this information persistently and also sends a register message to the server given in the server field. Persistently, means if we come back to this screen from the other one, or we leave the app and come back, these fields should be filled out as they were the last time we visited this screen.

When the mood viewer screen is entered and every minute thereafter that one is on this screen, it should send a status message to the server set on the settings screen. If no server has been set yet, it doesn't need to do this. This screen should be divided into three parts: a list view area (using a table in iOS, a ListView in Android), a slider area, and a text area with label Topic. The contents of a status message should be displayed, sorted in the list view. A list item should display a name, and the background color of the list item should be the mood value for that person that was sent back. The slider area ranges from 0 (white), 1 (red) to 5 (green). It is set to the value for the phone received from a status message (so changing the topic sets this to 0). In addition, if the user changes the slider value, then the new value is sent as a mood message to the server. The Topic text area should display the current topic, if a user edits it, and hits an adjacent Set button, a topic message should be sent to the server. If the user makes the keyboard go away without clicking set, the topic should revert to what the server has as the topic. This completes the description of the app.

For the CS286 students, I want you also to experiment with the the new eventsource features of HTML 5. These allow you to do push notifications. I want you to write a small app of your choice to demo this new feature of HTML 5. Include this program in Hw3.zip, also add to your readme.txt file a description of how to use it.

Point Breakdown

CS185c students: Coding Guidelines followed, code clean and well-documented, CS286-1 Students: eventsource example 1pt
MoodServer creates a ServerSocket bound to 7890 0.5pt
MoodServer handles each of the five messages correctly (0.5 each) 2.5pts
Phone app always stays in portrait mode 1pt
Phone app can switch between two screens and they appear as described 1pt
Phone app saves settings screen data persistently, sends register message as described (0.5 each) 1pt
Phone app sends status requests with frequency described above 1pt
Phone app updates list view accordingly after status message 1pt
Topic text field and set button work as described (Note if someone elese changes topic this field should update after a status message received this info) 1pt
Total10pts